//
// Copyright (c) 2009 All Right Reserved
//
// Stephen Toub
// stoub@microsoft.com
// 2009-01-01
// Contains ...
using System;
using System.IO;
using System.Text;
namespace LargoCommon.Midi
{
/// A system exclusive MIDI event.
[Serializable]
public sealed class MidiEventSystemExclusive : MidiEvent {
#region Fields
#endregion
#region Constructors
/// Initializes a new instance of the MidiEventSystemExclusive class.
/// The amount of time before this event.
private MidiEventSystemExclusive(long deltaTime) //// , byte[] givenData
: base(deltaTime) {
//// this.Data = givenData;
}
#endregion
#region Properties
/// Gets or sets the data for this event.
/// General musical property.
private byte[] Data { get; set; } //// virtual
#endregion
///
/// News the midi event system exclusive.
///
/// The delta time.
/// The given data.
/// Returns value.
public static MidiEventSystemExclusive NewMidiEventSystemExclusive(long deltaTime, byte[] givenData) {
var ev = new MidiEventSystemExclusive(deltaTime) { Data = givenData };
return ev;
}
#region To String
/// Generate a string representation of the event.
/// A string representation of the event.
public override string ToString() {
var sb = new StringBuilder();
sb.Append(base.ToString());
if (this.Data != null) {
sb.Append("\t");
}
sb.Append(MidiEvent.DataToString(this.Data));
return sb.ToString();
}
#endregion
#region Methods
/// Write the event to the output stream.
/// The stream to which the event should be written.
public override void Write(Stream outputStream) {
if (outputStream == null) {
return;
}
//// Write out the base event information
base.Write(outputStream);
//// Event data
outputStream.WriteByte((byte)MidiCommandCode.SystemExclusive);
MidiEvent.WriteVariableLength(outputStream, 1 + (this.Data?.Length ?? 0)); // "1+" for the F7 at the end
if (this.Data != null) {
outputStream.Write(this.Data, 0, this.Data.Length);
}
outputStream.WriteByte((byte)MidiCommandCode.EndOfSystemExclusive);
}
#endregion
}
}